package com.storm.lib.base;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.PropertyConfigurator;
import org.dom4j.Document;
import org.dom4j.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.storm.lib.generator.ProtocalBuilder;
import com.storm.lib.listener.FtpServerListener;
import com.storm.lib.task.SyncChatTask;
import com.storm.lib.task.SyncDBTask;
import com.storm.lib.task.SyncMapAvatarTask;
import com.storm.lib.task.TimerTask;
import com.storm.lib.template.TaskTemplate;
import com.storm.lib.type.TimerType;
import com.storm.lib.type.Timers;
import com.storm.lib.util.FileUtil;
import com.storm.lib.util.XMLUtil;
import com.storm.lib.vo.IdNumberVo;


/**
 * 
 * 类功能:初始化
 * @author johnny
 * @version 2011-8-18
 */
@Service
public abstract class BaseInitProcessor {
	@Autowired
	private TaskTemplate taskTemplate;
	@Autowired
	private FtpServerListener ftpServer;

	public void init(int[] timerTypes,Class[] clazzs){
//		new ProtocalBuilder().main(null);
		BasicConfigurator.configure();
//		ftpServer.init();
		PropertyConfigurator.configure(FileUtil.getUnderConfigFile("log4j.properties").getAbsolutePath()); 
		initAdditionalTasks();
		taskTemplate.executeTaskWhile(TimerTask.class);
		taskTemplate.executeTaskWhile(SyncMapAvatarTask.class);
		taskTemplate.executeTaskWhile(SyncChatTask.class);
		taskTemplate.executeTaskWhile(SyncDBTask.class);
		injectTimer(clazzs, timerTypes);
		System.out.println("初始化完成了");
	}
	
	public void injectTimer(Class[] clazz,int[] timerType) {
		TimerType.init(timerType,clazz);
	}
	

	public abstract void initAdditionalTasks();
	
}
